/*
 * @(#)UserAction.java 2009-2-24
 * Copyright (c) 2008-2015 by CJK
 * All rights reserved.
 */
package net.beyond.core.action;

import java.util.Date;

import net.beyond.common.struts2.BaseAction;
import net.beyond.core.entity.User;
import net.beyond.core.service.CoreService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

/**
 * 
 * @author Shmiluyu
 * @version 1.000 2009-2-24
 */
@Scope("prototype")
@Controller("userAction")
public class UserAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	private User user;

	public String add() {
		return ADD;
	}

	public String login() {
		return LOGIN;
	}

	/**
	 * �����û���Ϣ
	 * 
	 * @return
	 */
	public String save() {
		authService.registerUser(getUser());
		addActionMessage("ע�����û�");
		addActionMessage("�ɹ��ˣ�");
		return SUCCESS;
	}

	/**
	 * ��֤�û���½
	 * 
	 * @return
	 */
	public String validateLogin() {
		user = authService.validateUser(getUser());
		if (user == null) {
			addActionError("�û�����ڻ����������");
			return LOGIN;
		} else {
			return MANAGE;
		}
	}

	@Autowired
	private CoreService authService;

	public CoreService getAuthService() {
		return authService;
	}

	public void setAuthService(CoreService authService) {
		this.authService = authService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
